/**
 * 防抖函数
 */
function debounce(fun, time) {
  let timer
  return function () {
    clearTimeout(timer)
    let args = arguments
    timer = setTimeout(() => {
      fun.apply(this, args)
    }, time)
  }
}

/**
 * 节流函数
 */
function throttle(fun, time) {
  let t1 = 0
  return function () {
    let t2 = new Date().getTime()
    if (t2 - t1 > time) {
      t1 = t2
      return fun.apply(this, arguments)
    }
  }
}

/**
 * 测试函数
 */
function plus(a, b) {
  return a + b
}

/**
 * 兼容多种用法
 */
export { plus, throttle, debounce }
export default { plus, throttle, debounce }
